package org.example.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.example.domain.Post;
import org.example.dto.PostPageQueryDTO;
import org.example.mapper.PostMapper;
import org.example.result.PageResult;
import org.example.service.PostService;
import org.example.vo.PostVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
* @author Wangmengyi_1
* @description 针对表【sys_post】的数据库操作Service实现
* @createDate 2024-05-23 11:17:42
*/
@Service
public class PostServiceImpl implements PostService{
    @Autowired
    private PostMapper postMapper;

    @Override
    public PageResult listAll(PostPageQueryDTO postPageQueryDTO) {
        PageHelper.startPage(postPageQueryDTO.getPageNum(),postPageQueryDTO.getPageSize());
        Page<PostVo> page = postMapper.listAll(postPageQueryDTO);
        return PageResult.builder()
                .recodes(page)
                .total(page.getTotal())
                .build();
    }

    @Override
    public boolean save(PostPageQueryDTO postPageQueryDTO) {
        return postMapper.save(postPageQueryDTO);
    }

    @Override
    public boolean update(PostPageQueryDTO postPageQueryDTO) {
        return postMapper.update(postPageQueryDTO);
    }

    @Override
    public boolean removeById(Integer id) {
        return postMapper.removeById(id);
    }


}




